package com.mz361.modules.system.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mz361.common.enums.StatusEnum;
import com.mz361.common.utils.StatusUtil;
import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author niceale
 * @date 2023/10/24
 */
@Data
@Entity
@Table(name = "sys_member")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class Member implements Serializable {
    // 主键ID
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    // OPENID
    private String openId;
    // 用户昵称
    private String nickName;
    // 用户头像
    private String avatarUrl;
    // 用户性别
    private Byte gender;
    // 用户所在城市
    private String city;
    // 用户所在省份
    private String province;
    // 用户所在国家
    private String country;
    // 真实姓名
    private String relname;
    // 个性签名
    private String signature;
    // 手机号
    private String mobile;
    // 积分
    private Long score;
    // 金钱
    private BigDecimal money;
    // UNIONID
    private String unionid;
    // 备注
    private String remark;
    // 创建时间
    @CreatedDate
    private Date createDate;
    // 更新时间
    @LastModifiedDate
    private Date updateDate;
    // 创建者
    @CreatedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "create_by")
    @JsonIgnore
    private User createBy;
    // 更新者
    @LastModifiedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "update_by")
    @JsonIgnore
    private User updateBy;
    // 数据状态
    private Byte status = StatusEnum.OK.getCode();
}